#!/bin/env expect

set timeout -1 

if {$argc < 3} {
	puts "Descrption: Auto ssh login"
	puts "Usage: $argv0 <user> <host> <pwd>"
	exit 1
}

set user [lindex $argv 0]
set host [lindex $argv 1]
set pwd [lindex $argv 2]

spawn ssh $user@$host
expect {
	"\\\(yes/no\\\)\\\?" {
		send "yes\r"
		exp_continue
	}
	"*assword:" {send "$pwd\r"}
}

interact

